package cn.howxu.yichen_ovo.datagen;

import cn.howxu.yichen_ovo.registry.DollRegistryEvent;
import cn.howxu.yichen_ovo.init.ModBlocks;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.storage.loot.LootTable;

import java.util.*;

/**
 * @description: TODO
 * @author: HowXu
 * @date: 2025/9/16 13:29
 */
public class LootTableGenerator {
    public static class BlockLootTables extends BlockLootSubProvider {
        public final Set<Block> knownBlocks = new HashSet<>();

        public BlockLootTables() {
            super(Set.of(), FeatureFlags.REGISTRY.allFlags());
        }

        @Override
        public void generate() {
            DollRegistryEvent.BLOCKS.values().forEach(this::dropSelf);
            ModBlocks.BLOCKS.forEach(blockRegistryObject -> this.dropSelf(blockRegistryObject.get()));
            dropSelf(ModBlocks.ALBOOK.get());
            dropSelf(ModBlocks.FLAG.get());
            dropSelf(ModBlocks.WINE.get());
        }

        @Override
        public void add(Block block, LootTable.Builder builder) {
            this.knownBlocks.add(block);
            super.add(block, builder);
        }

        @Override
        public Iterable<Block> getKnownBlocks() {
            return this.knownBlocks;
        }
    }
}


